package com.serkol.utils;


import com.alibaba.fastjson.JSONObject;
import com.serkol.constant.AuthConstant;
import com.serkol.driving.learning.entity.LoginLog;
import com.serkol.utils.sm.SM4Utils;

import java.util.Arrays;
import java.util.List;


public class TokenUtils {


    public static LoginLog getAuth(String token) {
        SM4Utils sm4Utils = new SM4Utils();
        String s = sm4Utils.decryptData_ECB(token);
        System.out.println(s);
        LoginLog login = JSONObject.parseObject(s, LoginLog.class);
        if (login != null) {
            String s1 = "add,view,user,edit";
            String[] split = s1.split(",");
            List<String> strings = Arrays.asList(split);
            AuthConstant.setAuth(strings);
            AuthConstant.setLoginLog(login);
            System.out.println(login);
            return login;
        } else {
            return null;
        }

        // return login;
    }


}
